/**
 * 
 */
package com.stylefeng.guns.config;

import java.io.File;
import java.net.MalformedURLException;

import javax.annotation.Resource;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.stylefeng.guns.config.properties.GunsProperties;

/**
 * @author lzg
 *
 */
@Configuration
public class MyWebConfig extends WebMvcConfigurerAdapter{
	@Resource
    private GunsProperties gunsProperties;
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		// gunsProperties.getFileUploadPath()的值是d:/guns-upload
		try {
			File file = new File(gunsProperties.getFileUploadPath()+"ueditor/");
			String url = file.toURI().toURL().toString();
			super.addResourceHandlers(registry);
			registry.addResourceHandler("/file/**").addResourceLocations(url);  

		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
